<?php

$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';

$allow_origin = array(
    'http://dspc.anasit.com',
    'http://localhost:8081',
    'http://127.0.0.1:8081',
    'http://192.168.1.161:80',
    'http://127.0.0.1:4200',
    'http://192.168.1.186:4200',
    'http://192.168.1.186'
);

if (in_array($origin, $allow_origin)) {
    header('Access-Control-Allow-Origin:' . $origin);
    header('Access-Control-Allow-Methods:GET, POST, DELETE, PUT, OPTIONS');
    header('Access-Control-Allow-Headers:ng-params-one, ng-params-two, ng-params-three, ng-params-four, content-type, x-requested-with');
    // 只有同源策略才允许发送cookies
    header('Access-Control-Allow-Credentials:true');
}


if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
    return;
}
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
 */

$app = require __DIR__ . '/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
 */

$app->run();
